﻿using UnityEngine;
using System.Collections;

public class boss3move : MonoBehaviour {
    public int direction = -1;
    public float LeftRightSpeed = 20;
    Vector3[] randomDirection = new Vector3[] { -Vector3.right, Vector3.right };
    public Vector3 dir;
    int leftOrRight;

    void Start()
    {
        leftOrRight = Random.Range(0, 2);

    }

    void Update()
    {
        if (transform.position.x > WithinBounds.Bounds.maxX - 2)
        {
            if (leftOrRight == 1)
            {
                direction = -1;
            }
            else
                direction = 1;
            print(transform.position + "-");
        }
        else if (transform.position.x < WithinBounds.Bounds.minX + 2)
        {
            if (leftOrRight == 0)
            {
                direction = -1;
            }
            else
                direction = 1;
        }
        transform.position = transform.position + randomDirection[leftOrRight] * direction * LeftRightSpeed * Time.deltaTime;
    }


}
